<template>
    <div>
        <div class="playcontent" ref="playcontent">
            <ul class="radios" ref="radios">
                <li 
                v-for="(item, index) in djRadios" 
                :key="index">
                    <div class="djcover">
                        <van-image :src="item.picUrl" radius="0.5rem" width="4rem"/>
                        <div class="djcoverfont">
                            <div class="djtitle">{{ item.name }}</div>
                            <div>{{ item.playCount | numFilter(1) }}万次播放</div>
                            <div>{{ item.copywriter }}</div>
                        </div>
                    </div>       
                </li>
            </ul>
        </div>
    </div>
</template>
<script>
import { betterScrollHorizontal } from '../../../common/betterScroll';

export default {
    data(){
        return{
            djRadios:[] //播客
        };
    },
    created(){
        this.getdjData();
    },
    methods:{
        getdjData(){
            this.$request("get","/dj/recommend").then((res) => {
                console.log(res);
                this.djRadios = res.djRadios;
                betterScrollHorizontal(
                    this,
                    this.$refs.playcontent,
                    this.$refs.radios,
                    this.djRadios.length,
                    25
                    );
            });
        },
    },
    filters:{
        //处理播放量的显示格式
        //param num: 小数位固定地位置
        //param value: 处理的数值
        numFilter(value,num){
            return parseFloat(value / 10000).toFixed(num);
        },
    },
};
</script>
<style scoped>
.playcontent{
    width: 100%;
    overflow: hidden;
}
ul.radios li{
    display: inline-block;
    width:25rem;
    vertical-align: top;
}
.djcover{
    display: flex;
    text-align: left;
    margin: 30px;
    width: 20rem;
    border: 1px solid #000000;
    border-radius: 0.5rem;
    padding: 10px;
}
.djcoverfont{
    margin-left:10px;
    font-size: 10pt;
    overflow: hidden;/** 溢出的部分隐藏 */
    white-space: nowrap;/** 文本不换行 */
    text-overflow: ellipsis;/** ellipsis:文本溢出显示省略号; clip:不显示省略标记 */
}
.djtitle{
    font-size: 12pt;
    font-weight: bold;
}
</style>